package com.zhuiyun.project.api.plan.fitnessPlanAction.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.plan.fitnessPlanAction.entity.FitnessPlanAction;
import com.zhuiyun.project.api.plan.fitnessPlanAction.model.FitnessPlanActionModel;
import com.zhuiyun.project.api.plan.fitnessPlanAction.service.FitnessPlanActionService;
import com.zhuiyun.project.api.plan.fitnessType.entity.FitnessType;
import com.zhuiyun.project.api.plan.fitnessType.service.FitnessTypeService;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import com.zhuiyun.project.utils.pageUtil.PageResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName FitnessActionController
 * @Description TODO
 * @Author ys
 * @Date 2023/11/2 8:48
 **/
@RestController
@RequestMapping("/plan")
public class FitnessPlanActionController {
    @Autowired
    private FitnessPlanActionService fitnessPlanActionService;
    /**
    * @Author 杨珅
    * @Description todo 健身计划动作分页查询
    * @Date 2023/11/2 9:28
    * @Return  * @param null
    */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPlanAction')")
    @ApiOperation(value = "健身计划动作分页查询")
    @OptLog(modular = "健身计划动作列表", type = CommonConstants.SELECT, describe = "健身计划动作分页查询 ")
    @GetMapping("/getFitnessPlanAction")
            public CommonResult selectAll(PageRequest pageRequest,Integer fitnessPlanId,Integer fitnessTypeId,String fitnessActionName){
        PageResult pageResult = fitnessPlanActionService.selectAll(pageRequest,fitnessPlanId,fitnessTypeId, fitnessActionName);
        return CommonResult.ok(pageResult);
    }
    /**
     * @Author 杨珅
     * @Description todo 根据目的id全查标签
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPlanAction')")
    @ApiOperation(value = "根据目的id全查标签")
    @OptLog(modular = "健身计划动作列表", type = CommonConstants.SELECT, describe = "根据目的id全查标签 ")
    @GetMapping("/getFitnessTypes")
    public CommonResult selectTypes(PageRequest pageRequest,Integer fitnessPurposeId){
        PageResult pageResult = fitnessPlanActionService.selectTypes(pageRequest,fitnessPurposeId);
        return CommonResult.ok(pageResult);
    }
    /**
     * @Author 杨珅
     * @Description todo 健身计划动作新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPlanAction')")
    @ApiOperation(value = "健身计划动作新增")
    @OptLog(modular = "健身计划动作列表", type = CommonConstants.ADD, describe = "健身计划动作新增 ")
    @PostMapping("/addFitnessPlanAction")
    public CommonResult insertFitnessPlanAction(@RequestBody FitnessPlanActionModel fitnessPlanAction)throws CommonException {
        return CommonResult.ok(fitnessPlanActionService.insertFitnessPlanAction(fitnessPlanAction));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身计划动作修改
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPlanAction')")
    @ApiOperation(value = "健身计划动作修改")
    @OptLog(modular = "健身计划动作列表", type = CommonConstants.UPDATE, describe = "健身计划动作修改 ")
    @PutMapping("/updateFitnessPlanAction")
    public CommonResult updateFitnessPlanActione(@RequestBody FitnessPlanAction fitnessPlanAction)throws CommonException{
        return CommonResult.ok(fitnessPlanActionService.updateFitnessPlanAction(fitnessPlanAction));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身计划动作删除
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPlanAction')")
    @ApiOperation(value = "健身计划动作删除")
    @OptLog(modular = "健身计划动作列表", type = CommonConstants.DELETE, describe = "健身计划动作删除 ")
    @DeleteMapping("/deleteFitnessPlanAction")
    public CommonResult deleteFitnessPlanAction(@RequestBody FitnessPlanAction fitnessPlanAction){
        return CommonResult.ok(fitnessPlanActionService.deleteFitnessPlanAction(fitnessPlanAction));
    }
}
